package com.bjsxt.ego.back.controller;

import java.io.IOException;
import java.io.Serializable;
import java.lang.reflect.InvocationHandler;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.RandomAccess;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartFile;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.bjsxt.ego.common.controller.BaseController;
import com.bjsxt.ego.common.util.ConstatFinalUtil;
import com.bjsxt.ego.common.util.PageInfoUtil;
import com.bjsxt.ego.goods.pojo.Goods;
import com.bjsxt.ego.goods.pojo.GoodsBrand;
import com.bjsxt.ego.goods.pojo.GoodsBrandEnum;
import com.bjsxt.ego.goods.pojo.GoodsCategory;
import com.bjsxt.ego.goods.pojo.GoodsCategoryEnum;
import com.bjsxt.ego.goods.service.IGoodsService;
import com.bjsxt.ego.users.pojo.Admins;

/**
 *  商品的Controller
 * @author 章鸿敏
 *
 */
@Controller
@RequestMapping("/back/goods")
public class GoodsBackController extends BaseController
{
	@Resource
	private IGoodsService goodsService;
	
	/*----------品牌操作开始----------------*/
	/**
	 *  品牌列表
	 * @param request
	 * @return
	 */
	@RequestMapping("/brandList")
	public String brandList(HttpServletRequest request)
	{
		ConstatFinalUtil.LOGGER.info("---- brandList ----");
		/*接收条件*/
		String keyword = request.getParameter("keyword");
		String status = request.getParameter("status");
		String st = request.getParameter("st");
		String ed = request.getParameter("ed");
		/*处理搜索条件*/
		if (keyword == null)
		{
			keyword = "";
		}
		/*去除两边的空格*/
		keyword = keyword.trim();
		if (status == null)
		{
			status = "";
		}
		if (st == null)
		{
			st = "";
		}
		if (ed == null)
		{
			ed = "";
		}
		
		Date stDate = null;
		Date edDate = null;
		if (!"".equalsIgnoreCase(st) && !"".equalsIgnoreCase(ed))
		{
			stDate =this.dateFormatUtil.parseDateTime(st);
			edDate = this.dateFormatUtil.parseDateTime(ed);
		}
		
		Map<String, Object> condMap = new HashMap<String,Object>();
		condMap.put("keyword", keyword);
		if (!"".equalsIgnoreCase(status))
		{
			condMap.put("status", status);
		}
		condMap.put("stDate", stDate);
		condMap.put("edDate", edDate);
		/*分页*/
		PageInfoUtil pageInfoUtil = this.processPageInfo(request);
		/*查询*/
		List<GoodsBrand> goodsBrandList = this.goodsService.findCondListGoodsBrandService(pageInfoUtil, condMap);
		/*储存结果*/
		request.setAttribute("goodsBrandList", goodsBrandList);
		request.setAttribute("pageInfoUtil", pageInfoUtil);
		request.setAttribute("websitePath", ConstatFinalUtil.BUNDLE.getString("website.path"));
		
		/*储存条件*/
		request.setAttribute("keyword", keyword);
		request.setAttribute("status", status);
		request.setAttribute("st", st);
		request.setAttribute("ed", ed);
		
		return "/back/goods/brandList";
	}
	
	/**
	 *  品牌添加
	 * @return
	 */
	@RequestMapping("/brandInsert")
	public String brandInsert()
	{
		ConstatFinalUtil.LOGGER.info("---- brandInsert ----");
		return "/back/goods/brandInsert";
	}
	
	/**
	 *  品牌添加提交
	 * @param request
	 * @param goodsBrand
	 * @param file
	 * @return
	 * @throws IOException 
	 */
	@RequestMapping("/brandInsertSubmit")
	/*
	 * 在提交的方法中加入GoodsBrand是使用了属性驱动，表单中有的列在方法中不需要获取，是因为使用驱动自动赋值
	 * 下面手动赋值的都是不需要用户填写的列,如这个操作是属于哪个管理员添加的,创建时间,更新时间等
	 * 对于发布时间来说,驱动对于时间都不能直接赋值,需要自己手动转换,所以，对于时间类型的需要我们手动赋值
	 * */
	public String brandInsertSubmit(HttpServletRequest request,GoodsBrand goodsBrand,MultipartFile file) throws IOException
	{
		ConstatFinalUtil.LOGGER.info("---- brandInsertSubmit ----");
		HttpSession session = request.getSession();
		/*处理管理员*/
		Admins admins = (Admins) session.getAttribute("admins");
		goodsBrand.setAdminsId(admins.getId());
		
		/*处理从前台获取的发布时间*/
		String pubTimeStr = request.getParameter("pubTimeStr");
		goodsBrand.setPubTime(this.dateFormatUtil.parseDateTime(pubTimeStr));
		
		/*处理系统自动生成的时间*/
		goodsBrand.setCreateTime(new Date());
		goodsBrand.setUpdateTime(new Date());
		
		Map<String, Object> paramsMap = new HashMap<String,Object>();
		if (file != null)
		{
			/*获取原始文件的名称*/
			paramsMap.put("oriFileName", file.getOriginalFilename());
			/*获取原始文件的输入流*/
			paramsMap.put("inputStream", file.getInputStream());
		}
		JSONObject resultJSON = this.goodsService.saveOneGoodsBrandService(goodsBrand, paramsMap);
		this.info = resultJSON.getString("info");
		request.setAttribute("info", info);
		return this.brandInsert();
	}
	
	/**
	 *  品牌更新
	 * @param request
	 * @param bid
	 * @return
	 */
	@RequestMapping("/brandUpdate")
	public String brandUpdate(HttpServletRequest request,String bid)
	{
		ConstatFinalUtil.LOGGER.info("---- brandUpdate ----");
		/*根据id查询*/
		Map<String, Object> condMap = new HashMap<String,Object>();
		condMap.put("id", bid);
		/*查询数据库*/
		GoodsBrand goodsBrand = this.goodsService.findOneGoodsBrandService(condMap);
		/*存储到request的作用域中*/
		request.setAttribute("goodsBrand", goodsBrand);
		/*因为在更新的jsp页面，在修改LOGO时需要显示原LOGO，所有需要用到weisite，因此需要再翻去作用域中*/
		request.setAttribute("websitePath",ConstatFinalUtil.BUNDLE.getString("website.path"));
		return "/back/goods/brandUpdate";
	}
	
	/**
	 *  品牌更新提交
	 * @param request
	 * @param bid
	 * @param file
	 * @return
	 * @throws IOException 
	 */
	@RequestMapping("/brandUpdateSubmit")
	public String brandUpdateSubmit(HttpServletRequest request,String bid,MultipartFile file) throws IOException
	{
		ConstatFinalUtil.LOGGER.info("---- brandUpdateSubmit ----");
		/*根据id查询*/
		Map<String, Object> condMap = new HashMap<String,Object>();
		condMap.put("id", bid);
		/*查询数据库*/
		GoodsBrand goodsBrand = this.goodsService.findOneGoodsBrandService(condMap);
		/*存储到request的作用域中*/
		request.setAttribute("goodsBrand", goodsBrand);
		
		String pubTime = request.getParameter("pubTime");
		goodsBrand.setPubTime(this.dateFormatUtil.parseDateTime(pubTime));
		
		String name = request.getParameter("name");
		String website = request.getParameter("website");
		String content = request.getParameter("content");
		String status = request.getParameter("status");
		
		goodsBrand.setName(name);
		goodsBrand.setWebsite(website);
		goodsBrand.setContent(content);
		goodsBrand.setStatus(Byte.valueOf(status));
		
		goodsBrand.setUpdateTime(new Date());
		
		Map<String, Object> paramsMap = new HashMap<String,Object>();
		/*获取原始文件*/
		if (file != null)
		{
			paramsMap.put("oriFileName", file.getOriginalFilename());
			paramsMap.put("inputStream", file.getInputStream());
		}
		
		JSONObject resultJSON = this.goodsService.updateOneGoodsBrandService(goodsBrand, paramsMap);
		this.info = resultJSON.getString("info");
		request.setAttribute("info", info);
		return this.brandUpdate(request, bid);
	}
	
	/*----------品牌操作结束----------------*/
	
	/*----------分类操作开始----------------*/
	/**
	 *  分类列表
	 * @param request
	 * @return
	 */
	@RequestMapping("/categoryList")
	public String categoryList(HttpServletRequest request)
	{
		ConstatFinalUtil.LOGGER.info("---- categoryList ----");
		/*接收条件*/
		String keyword = request.getParameter("keyword");
		String status = request.getParameter("status");
		String st = request.getParameter("st");
		String ed = request.getParameter("ed");
		
		/*处理搜索条件*/
		if (keyword == null)
		{
			keyword = "";
		}
		/*去除两边的空格*/
		keyword = keyword.trim();
		if (status == null)
		{
			status = "";
		}
		if (st == null)
		{
			st = "";
		}
		if (ed == null)
		{
			ed = "";
		}
		
		Date stDate = null;
		Date edDate = null;
		if (!"".equalsIgnoreCase(st) && !"".equalsIgnoreCase(ed))
		{
			stDate =this.dateFormatUtil.parseDateTime(st);
			edDate = this.dateFormatUtil.parseDateTime(ed);
		}
		
		Map<String, Object> condMap = new HashMap<String,Object>();
		condMap.put("keyword", keyword);
		if (!"".equalsIgnoreCase(status))
		{
			condMap.put("status", status);
		}
		condMap.put("stDate", stDate);
		condMap.put("edDate", edDate);
		/*分页*/
		PageInfoUtil pageInfoUtil = this.processPageInfo(request);
		/*查询*/
		List<GoodsCategory> goodsCategoryList = this.goodsService.findCondListGoodsCategoryService(pageInfoUtil, condMap);
		/*储存结果*/
		request.setAttribute("goodsCategoryList", goodsCategoryList);
		request.setAttribute("pageInfoUtil", pageInfoUtil);
		
		/*储存条件*/
		request.setAttribute("keyword", keyword);
		request.setAttribute("status", status);
		request.setAttribute("st", st);
		request.setAttribute("ed", ed);
		
		return "/back/goods/categoryList";
		
	}
	
	/*
	 * 分类列表
	 *  树形菜单
	 * */
	@RequestMapping("/categoryTreeList")
	public String categoryTreeList(HttpServletRequest request)
	{
		ConstatFinalUtil.LOGGER.info("---- categoryTreeList ----");
		Map<String, Object> condMap = new HashMap<String,Object>();
		condMap.put("parentId", "0");
		/*先查询出所有分类的集合*/
		List<GoodsCategory> goodsCategoryList = this.goodsService.findCondListGoodsCategoryService(null, condMap);
		/*树形结构*/
		JSONArray goodsCategoryTreeArr = this.goodsService.findTreeGoodsCategoryService(goodsCategoryList,request.getContextPath());
		request.setAttribute("goodsCategoryTreeArr", goodsCategoryTreeArr);
		return "/back/goods/categoryTreeList";
	}
	
	/**
	 *  分类添加
	 * @return
	 */
	@RequestMapping("/categoryInsert")
	public String categoryInsert()
	{
		ConstatFinalUtil.LOGGER.info("---- categoryInsert ----");
		return "/back/goods/categoryInsert";
	}
	
	/**
	 *  分类添加提交
	 * @param request
	 * @param goodsCategory
	 * @param file
	 * @return
	 * @throws IOException 
	 */
	
	/*
	 * 在提交的方法中加入GoodsCategory是使用了属性驱动，表单中有的列在方法中不需要获取，是因为使用驱动自动赋值
	 * 下面手动赋值的都是不需要用户填写的列,如这个操作是属于哪个管理员添加的,创建时间,更新时间等
	 * 对于发布时间来说,驱动对于时间都不能直接赋值,需要自己手动转换,所以，对于时间类型的需要我们手动赋值
	 * */
	@RequestMapping("/categoryInsertSubmit")
	public String categoryInsertSubmit(HttpServletRequest request,GoodsCategory goodsCategory) 
	{
		ConstatFinalUtil.LOGGER.info("---- categoryInsertSubmit ----");
		HttpSession session = request.getSession();
		/*处理管理员*/
		Admins admins = (Admins) session.getAttribute("admins");
		goodsCategory.setAdminsId(admins.getId());
		
		/*处理从前台获取的发布时间*/
		String pubTimeStr = request.getParameter("pubTimeStr");
		goodsCategory.setPubTime(this.dateFormatUtil.parseDateTime(pubTimeStr));
		
		/*处理系统自动生成的时间*/
		goodsCategory.setCreateTime(new Date());
		goodsCategory.setUpdateTime(new Date());
		
		JSONObject resultJSON = this.goodsService.saveOneGoodsCategoryService(goodsCategory);
		this.info = resultJSON.getString("info");
		request.setAttribute("info", info);
		return this.categoryInsert();
	}
	
	/**
	 *  分类更新
	 * @param request
	 * @param bid
	 * @return
	 */
	@RequestMapping("/categoryUpdate")
	public String categoryUpdate(HttpServletRequest request,String cid)
	{
		ConstatFinalUtil.LOGGER.info("---- categoryUpdate ----");
		/*根据id查询*/
		Map<String, Object> condMap = new HashMap<String,Object>();
		condMap.put("id", cid);
		/*查询数据库*/
		GoodsCategory goodsCategory = this.goodsService.findOneGoodsCategoryService(condMap);
		/*存储到request的作用域中*/
		request.setAttribute("goodsCategory", goodsCategory);
		
		return "/back/goods/categoryUpdate";
	}
	
	/**
	 *  分类更新提交
	 * @param request
	 * @param bid
	 * @param file
	 * @return
	 * @throws IOException 
	 */
	@RequestMapping("/categoryUpdateSubmit")
	public String categoryUpdateSubmit(HttpServletRequest request,String cid) 
	{
		ConstatFinalUtil.LOGGER.info("---- categoryUpdateSubmit ----");
		/*根据id查询*/
		Map<String, Object> condMap = new HashMap<String,Object>();
		condMap.put("id", cid);
		/*查询数据库*/
		GoodsCategory goodsCategory = this.goodsService.findOneGoodsCategoryService(condMap);
		/*存储到request的作用域中*/
		request.setAttribute("goodsCategory", goodsCategory);
		
		String pubTime = request.getParameter("pubTime");
		goodsCategory.setPubTime(this.dateFormatUtil.parseDateTime(pubTime));
		
		String name = request.getParameter("name");
		String url = request.getParameter("url");
		String spec = request.getParameter("spec");
		String content = request.getParameter("content");
		String status = request.getParameter("status");
		
		goodsCategory.setName(name);
		goodsCategory.setUrl(url);
		goodsCategory.setSpec(spec);
		goodsCategory.setContent(content);
		goodsCategory.setStatus(Byte.valueOf(status));
		
		goodsCategory.setUpdateTime(new Date());
		
		JSONObject resultJSON = this.goodsService.updateOneGoodsCategoryService(goodsCategory);
		this.info = resultJSON.getString("info");
		request.setAttribute("info", info);
		return this.categoryUpdate(request, cid);
	}
	
	/*----------分类操作结束----------------*/
	
	/*----------商品操作开始----------------*/
	/**
	 *  商品列表
	 * @param request
	 * @return
	 */
	@RequestMapping("/goodsList")
	public String goodsList(HttpServletRequest request)
	{
		ConstatFinalUtil.LOGGER.info("---- goodsList ----");
		/*接收条件*/
		String keyword = request.getParameter("keyword");
		String status = request.getParameter("status");
		String st = request.getParameter("st");
		String ed = request.getParameter("ed");
		/*处理搜索条件*/
		if (keyword == null)
		{
			keyword = "";
		}
		/*去除两边的空格*/
		keyword = keyword.trim();
		if (status == null)
		{
			status = "";
		}
		if (st == null)
		{
			st = "";
		}
		if (ed == null)
		{
			ed = "";
		}
		
		Date stDate = null;
		Date edDate = null;
		if (!"".equalsIgnoreCase(st) && !"".equalsIgnoreCase(ed))
		{
			stDate =this.dateFormatUtil.parseDateTime(st);
			edDate = this.dateFormatUtil.parseDateTime(ed);
		}
		
		Map<String, Object> condMap = new HashMap<String,Object>();
		condMap.put("keyword", keyword);
		if (!"".equalsIgnoreCase(status))
		{
			condMap.put("status", status);
		}
		condMap.put("stDate", stDate);
		condMap.put("edDate", edDate);
		/*分页*/
		PageInfoUtil pageInfoUtil = this.processPageInfo(request);
		/*查询*/
		List<Goods> goodsList = this.goodsService.findCondListGoodsService(pageInfoUtil, condMap);
		/*储存结果*/
		request.setAttribute("goodsList", goodsList);
		request.setAttribute("pageInfoUtil", pageInfoUtil);
		request.setAttribute("websitePath", ConstatFinalUtil.BUNDLE.getString("website.path"));
		/*储存条件*/
		request.setAttribute("keyword", keyword);
		request.setAttribute("status", status);
		request.setAttribute("st", st);
		request.setAttribute("ed", ed);
		
		return "/back/goods/goodsList";
	}
	
	/**
	 *  商品添加
	 * @return
	 */
	@RequestMapping("/goodsInsert")
	public String goodsInsert(HttpServletRequest request)
	{
		ConstatFinalUtil.LOGGER.info("---- goodsInsert ----");
		Map<String, Object> condMap = new HashMap<String,Object>();
		/*因为是需要管理员在添加的时候选择的,所有查询的条件就需要为开启状态的分类,所以按照状态查询*/
		condMap.put("status",GoodsCategoryEnum.STATUS_ENABLE.getStatus());
		/*查询出关联的分类*/
		/*List<GoodsCategory> goodsCategoryList = this.goodsService.findCondListGoodsCategoryService(null, condMap);*/
		condMap.put("parentId", "0");
		List<GoodsCategory> goodsCategoryList = this.goodsService.findCondListGoodsCategoryService(null, condMap);
		/**
		 *  JSONArray  从源码中看到public class JSONArray extends JSON implements List<Object>, Cloneable, RandomAccess, Serializable 
		 *  从源码的实现关系来看JSONArray其实本质上是一个list数组,list数组可以在前端页面使用jstl进行遍历,所以总格JSONArray可以直接在前台页面遍历
		 *  JSONObject 从源码中看到public class JSONObject extends JSON implements Map<String, Object>, Cloneable, Serializable, InvocationHandler
		 *  JSONObject 本质是一个map键值对
		 */
		JSONArray goodsCategoryTreeArr = this.goodsService.findTreeGoodsCategoryService(goodsCategoryList, request.getContextPath());
		condMap.clear();
		condMap.put("status", GoodsBrandEnum.STATUS_ENABLE.getStatus());
		/*查询开启的品牌*/
		List<GoodsBrand> goodsBrandList = this.goodsService.findCondListGoodsBrandService(null, condMap);
		
		/*将查询出来的分类和品牌放入到作用域中,用于前台页面的获取*/
		request.setAttribute("goodsCategoryTreeArr", goodsCategoryTreeArr);
		
		request.setAttribute("goodsCategoryList", goodsCategoryList);
		request.setAttribute("goodsBrandList", goodsBrandList);
		return "/back/goods/goodsInsert";
	}
	
	/**
	 *  商品添加提交
	 * @param request
	 * @param goods
	 * @param file
	 * @return
	 * @throws IOException 
	 */
	@RequestMapping("/goodsInsertSubmit")
	/*
	 * 在提交的方法中加入Goods是使用了属性驱动，表单中有的列在方法中不需要获取，是因为使用驱动自动赋值
	 * 下面手动赋值的都是不需要用户填写的列,如这个操作是属于哪个管理员添加的,创建时间,更新时间等
	 * 对于发布时间来说,驱动对于时间都不能直接赋值,需要自己手动转换,所以，对于时间类型的需要我们手动赋值
	 * */
	public String goodsInsertSubmit(HttpServletRequest request,Goods goods,MultipartFile file) throws IOException
	{
		ConstatFinalUtil.LOGGER.info("---- goodsInsertSubmit ----");
		HttpSession session = request.getSession();
		/*处理管理员*/
		Admins admins = (Admins) session.getAttribute("admins");
		goods.setAdminsId(admins.getId());
		
		/*处理从前台获取的发布时间*/
		String pubTimeStr = request.getParameter("pubTimeStr");
		goods.setPubTime(this.dateFormatUtil.parseDateTime(pubTimeStr));
		
		/*处理系统自动生成的时间*/
		goods.setCreateTime(new Date());
		goods.setUpdateTime(new Date());
		
		Map<String, Object> paramsMap = new HashMap<String,Object>();
		
		if (file != null)
		{
			/*获取原始文件的名称*/
			paramsMap.put("oriFileName", file.getOriginalFilename());
			/*获取原始文件的输入流*/
			paramsMap.put("inputStream", file.getInputStream());
		}
		
		JSONObject resultJSON = this.goodsService.saveOneGoodsService(goods,paramsMap);
		this.info = resultJSON.getString("info");
		request.setAttribute("info", info);
		return this.goodsInsert(request);
	}
	
	/**
	 *  商品更新
	 * @param request
	 * @param bid
	 * @return
	 */
	@RequestMapping("/goodsUpdate")
	public String goodsUpdate(HttpServletRequest request,String gid)
	{
		ConstatFinalUtil.LOGGER.info("---- goodsUpdate ----");
		/*根据id查询*/
		Map<String, Object> condMap = new HashMap<String,Object>();
		condMap.put("id", gid);
		/*查询数据库*/
		Goods goods = this.goodsService.findOneGoodsService(condMap);
		/*查询所有开启状态的商品品牌，此处是查询出下拉框下的所有开启状态的商品的品牌*/
		condMap.clear();
		condMap.put("status",GoodsBrandEnum.STATUS_ENABLE.getStatus());
		List<GoodsBrand> goodsBrandList = this.goodsService.findCondListGoodsBrandService(null, condMap);
		/*查询所有开启状态的树形结构的分类,此处是查询出分类下拉框下所有开启状态的商品的分类*/
		condMap.clear();
		condMap.put("status", GoodsCategoryEnum.STATUS_ENABLE.getStatus());
		condMap.put("parentId", "0");
		/*查询根节点*/
		List<GoodsCategory> goodsCategoryList = this.goodsService.findCondListGoodsCategoryService(null, condMap);
		/*查询整棵数*/
		JSONArray goodsCategoryTreeArr =this.goodsService.findTreeGoodsCategoryService(goodsCategoryList, request.getContextPath());
		
		/*存储到request的作用域中*/
		request.setAttribute("goods", goods);
		request.setAttribute("goodsBrandList", goodsBrandList);
		request.setAttribute("goodsCategoryTreeArr", goodsCategoryTreeArr);
		/*图片的网路路径,无此路径图片将无法正常显示*/
		request.setAttribute("websitePath", ConstatFinalUtil.BUNDLE.getString("website.path"));
		return "/back/goods/goodsUpdate";
	}
	
	/**
	 *  商品更新提交
	 * @param request
	 * @param bid
	 * @param file
	 * @return
	 * @throws IOException 
	 */
	@RequestMapping("/goodsUpdateSubmit")
	public String goodsUpdateSubmit(HttpServletRequest request,String gid,MultipartFile file) throws IOException
	{
		ConstatFinalUtil.LOGGER.info("---- goodsUpdateSubmit ----");
		/*根据id查询*/
		Map<String, Object> condMap = new HashMap<String,Object>();
		condMap.put("id", gid);
		/*查询数据库*/
		Goods goods = this.goodsService.findOneGoodsService(condMap);
		/*存储到request的作用域中*/
		request.setAttribute("goods", goods);
		
		String pubTime = request.getParameter("pubTime");
		goods.setPubTime(this.dateFormatUtil.parseDateTime(pubTime));
		
		String cateId = request.getParameter("cateId");
		String brandId = request.getParameter("brandId");
		String name = request.getParameter("name");
		String title = request.getParameter("title");
		String url = request.getParameter("url");
		String weight = request.getParameter("weight");
		String remainNum = request.getParameter("remainNum");
		String marketPrice = request.getParameter("marketPrice");
		String price = request.getParameter("price");
		String content = request.getParameter("content");
		String status = request.getParameter("status");
		
		goods.setCateId(Integer.valueOf(cateId));
		goods.setBrandId(Integer.valueOf(brandId));
		goods.setName(name);
		goods.setTitle(title);
		goods.setUrl(url);
		goods.setWeight(Double.valueOf(weight));
		goods.setRemainNum(Integer.valueOf(remainNum));
		goods.setMarketPrice(Double.valueOf(marketPrice));
		goods.setPrice(Double.valueOf(price));
		goods.setContent(content);
		goods.setStatus(Byte.valueOf(status));
		
		goods.setUpdateTime(new Date());
		
		Map<String, Object> paramsMap = new HashMap<String,Object>();
		/*获取原始文件*/
		if (file != null)
		{
			paramsMap.put("oriFileName", file.getOriginalFilename());
			paramsMap.put("inputStream", file.getInputStream());
		}
		JSONObject resultJSON = this.goodsService.updateOneGoodsService(goods, paramsMap);
		this.info = resultJSON.getString("info");
		request.setAttribute("info", info);
		return this.goodsUpdate(request, gid);
	}
	
	/*----------商品操作结束----------------*/
}
